package com.ray.bean;

import java.text.SimpleDateFormat;
import java.util.Date;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

import com.ray.util.StringUtil;
import com.ray.util.TimeAndUnix;
@Getter
@ToString
@EqualsAndHashCode
public class TemporalIntervalBean {
	

	private String timeIntervalId;
	
	private String startTime;
	
	private String endTime;
	
	public TemporalIntervalBean() {}

	public TemporalIntervalBean(String startTime,
			String endTime) {
		this.timeIntervalId = StringUtil.getUUID();
		this.startTime = startTime;
		this.endTime = endTime;
	}
	
	/**
	 * 
	 * @Title: checkNowInTemporalInterval  
	 * @author: 李宇航 
	 * @Description: 检查当前时间是否在时间区间内    在返回true，不在返回false
	 * @return: boolean      
	 * @throws
	 */
	public boolean checkNowInTemporalInterval(){
		String startTime=this.startTime.split(" ")[1];
		String endTime=this.endTime.split(" ")[1];
		SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
		Date date = new Date();
		String now=format.format(date);
		return TimeAndUnix.compTime(now, startTime)&&TimeAndUnix.compTime(endTime, now);
	}
	
	
}
